const { addAdmins, getAdmins, editAdmins, deleteAdmins, switchAdmins } = require('../dao/adminsDao.js')

//新增管理员
module.exports.addAdmins = async admin => {
    const data = await addAdmins(admin);
    if (data) {
        return {
            message: '新增管理员成功',
            status: 1,
            data
        }
    }
    return {
        message: '新增失败',
        status: 0,
    }
}

//获取所有管理员
module.exports.getAdmins = async admin => {
    const data = await getAdmins(admin);
    if (data) {
        return {
            message: '获取管理员成功',
            status: 1,
            data
        }
    }
    return {
        message: '获取失败',
        status: 0,
    }
}

//update
module.exports.editAdmins = async admin => {
    const data = await editAdmins(admin);
    if (data) {
        return {
            message: '修改管理员成功',
            status: 1,
            data
        }
    }
    return {
        message: '修改失败',
        status: 0,
    }
}

//delete
module.exports.deleteAdmins = async admin => {
    const data = await deleteAdmins(admin);
    if (data) {
        return {
            message: '删除管理员成功',
            status: 1,
            data
        }
    }
    return {
        message: '删除失败',
        status: 0,
    }
}

//switchAdmins
module.exports.switchAdmins = async status => {
    const data = await switchAdmins(status);
    if (data) {
        return {
            message: '状态设置成功',
            status: 1,
            data
        }
    }
    return {
        message: '更新失败',
        status: 0,
    }
}